/**
 * XMLFlightGenerator.java
 * Dec 28, 2009
 */
package com.dlplay.flightinfo.presentation;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import com.dlplay.flightinfo.data.FlightInfo;

/**
 * @author zhao yu
 *
 */
public class XMLFlightGenerator implements XMLGenerator {

	private FlightInfo data;
	public XMLFlightGenerator(FlightInfo flight) {
		data = flight;
	}

	/* (non-Javadoc)
	 * @see com.dlplay.flightinfo.server.XMLGenerator#generate(org.w3c.dom.Document)
	 */
	@Override
	public void generate(Document document) {
		Element eltItem = document.createElement("Flight");
		Element eltNum = document.createElement("Number");
		Element eltStatus = document.createElement("Status");
		Element eltFrom = document.createElement("from");
		Element eltTo = document.createElement("to");

		Element eltReception = document.createElement("reception");
		Element eltPlanArrival = document.createElement("planArrival");
		
//		eltNum.appendChild(document.createTextNode(data.getNumber()));
//		eltStatus.appendChild(document.createTextNode(data.getStatus()));
//		eltFrom.appendChild(document.createTextNode(data.getFrom()));
//		eltTo.appendChild(document.createTextNode(data.getTo()));
//		eltReception.appendChild(document.createTextNode(data.getReception()));
//		eltPlanArrival.appendChild(document.createTextNode(data.getPlanArrival().toString()));
		
		
		eltItem.appendChild(eltNum);
		eltItem.appendChild(eltStatus);
		eltItem.appendChild(eltFrom);
		eltItem.appendChild(eltTo);
		eltItem.appendChild(eltReception);
		eltItem.appendChild(eltPlanArrival);

		document.appendChild(eltItem);
		document.normalizeDocument();
	}

}
